<?php

use Phinx\Migration\AbstractMigration;

class CreateStaffTable extends AbstractMigration
{
    public function change()
    {
        $table = $this->table('staff');
        $table->addColumn('username', 'string', ['limit' => 50, 'comment' => '用户名'])
            ->addColumn('password', 'string', ['limit' => 255, 'comment' => '密码'])
            ->addColumn('salt', 'string', ['limit' => 32, 'comment' => '密码盐'])
            ->addColumn('real_name', 'string', ['limit' => 50, 'null' => true, 'comment' => '真实姓名'])
            ->addColumn('mobile', 'string', ['limit' => 20, 'null' => true, 'comment' => '手机号'])
            ->addColumn('email', 'string', ['limit' => 100, 'null' => true, 'comment' => '邮箱'])
            ->addColumn('avatar', 'string', ['limit' => 255, 'null' => true, 'comment' => '头像'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态：0=禁用，1=启用'])
            ->addColumn('created_at', 'timestamp', ['null' => true])
            ->addColumn('updated_at', 'timestamp', ['null' => true])
            ->addIndex(['username'], ['unique' => true])
            ->addIndex(['mobile'])
            ->addIndex(['email'])
            ->addIndex(['status'])
            ->create();
    }
} 